//
//  KLPeerRemote.h
//  WebRTCDemo_iOS
//
//  Created by szblsx2 on 2020/3/5.
//  Copyright © 2020 szblsx2. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "KLAppDefine.h"
@class KLClient;
@class KLPeerRemote;

NS_ASSUME_NONNULL_BEGIN

@protocol KLPeerRemoteDelegate <NSObject>

@required
// 获取到远端视频流
- (void)klPeerRemote:(KLPeerRemote *)peerRemote addRemoteStream:(RTCMediaStream *)mediaStream streamId:(NSString *)streamId userId:(NSString *)userId;

@end

@interface KLPeerRemote : NSObject
//房间id
@property (nonatomic, copy) NSString *roomId;
//订阅id
@property (nonatomic, copy) NSString *subId;
//流id
@property (nonatomic, copy) NSString *streamId;
//用户id
@property (nonatomic, copy) NSString *userId;
//delegate
@property (nonatomic, weak) id<KLPeerRemoteDelegate> delegate;
//临时变量 控制远端是否开启扬声器
@property (nonatomic, assign) BOOL openSpeaker;

/**
*  初始化PeerRemote
*  @param client          信令对象
*  @param factory        连接工厂
*  @param iceServers  ice服务器地址集合
*/
- (instancetype)initWithClient:(KLClient *)client
                         factory:(RTCPeerConnectionFactory *)factory
                      iceServers:(NSArray<RTCIceServer *>*)iceServers;

/**
*  创建PeerConnection
*/
- (void)initPeerConnection;

/**
*  删除PeerConnection
*/
- (void)freePeerConnection;

/**
*  创建offer SDP
*/
- (void)createOffer;

/**
*  接收到远端answer SDP处理
*  @param sessionDescription    远端sdp描述
*/
- (void)onRemoteDescription:(RTCSessionDescription *)sessionDescription;

/**
*  从服务器取消订阅流
*/
- (void)sendUnSubscribe;

@end

NS_ASSUME_NONNULL_END
